package cn.lg.util;

import lombok.Data;

/**
 * @ProjectName pethome
 * @ClassName AjaxResult
 * @Description 异步操作结果工具类
 * @Author Administrator
 * @Date 2022/4/21 11:12
 * @Version 1.0
 **/
@Data
public class AjaxResult {
    //操作是否成功
    private Boolean success = true;
    //操作提示语
    private String msg = "操作成功";
    //用来封装额外的返回参数
    private Object resultObj;



    public static AjaxResult getAjaxResult(){
        return new AjaxResult();
    }

    //创建两个方法的set方法，修改返回值类型为AjaxResult，这样便于链式编程进行值得设置


    public AjaxResult setSuccess(Boolean success) {
        this.success = success;
        return this;
    }


    public AjaxResult setMsg(String msg){
        this.msg=msg;
        return this;
    }

    public static AjaxResult success(){
        return new AjaxResult();
    }

    public static AjaxResult error(){
        return new AjaxResult().setSuccess(false).setMsg("系统繁忙，请重试!");
    }

    public  AjaxResult setResultObj(Object resultObj){
        this.resultObj = resultObj;
        return this;
    }

}
